/**
	韩飞 树状结构引用
**/
var _c = "/pressystem";
var _cc = _c;
var _dynamic = "/parts/itemjs/sort/dynamic/";
var _image = "/parts/images";
var _pageFullLoaded = false;
var _JUICECLASSES = [];
var _CONFIG = [];
_CONFIG['developer.mode']=false;

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},

		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();

function __addEvent(oEventTarget, sEventType, fDest){
	//兼容其他浏览器
	if (window.addEventListener != undefined ){
		oEventTarget.addEventListener(sEventType.substr(2), fDest, false);
	} else if (window.attachEvent != undefined){
	    oEventTarget.attachEvent(sEventType, fDest);
	}
	EventCache.add(oEventTarget, sEventType, fDest);
};



window.onunload = EventCache.flush;

__addEvent(window, "onload", __startOnload);
__addEvent(window, "onunload", __clear);

function __startEd() {
  _pageFullLoaded = true;
}

function __startOnload() {
  __start();  
  _pageFullLoaded = true;
}
function __start() {
    var d = null;
    try {
      d = window.document;
    }catch(e){      
      return;
    }
    __render(d.all.tags("DIV"));
    __render(d.all.tags("SELECT"));
    __render(d.all['COMP']);
    
    //document.body.oncontextmenu = new Function("return false;");
    //下面为临时使用的方法，当按下鼠标右键时复制文件名至剪贴板当中
    if (_CONFIG['developer.mode']==true) {
      __addEvent(document.body, "onmousedown", getFileNameTest);
    }
    __ipRender("INPUT");
    __ipRender("TEXTAREA");
    /** if it's an jwin then set the background-color */
    if (__isJwindow()) {
      if (document.body.getAttribute("tt.importance")==null) {
        document.body.style.backgroundColor = "#f7f3f7";
      }      
    }
    /** if it's and jwin then call an init function */
    if (__isJwindow()) {
      parent.STATICCLASS_JWINDOW.loadFix();
    }
    if (typeof(top.__unJump)!="undefined") {
      top.__unJump();
    }
    __renderSpecialStyle();
    document.body.style.display = "";
    setTimeout(reCheck,2000);
    function reCheck() {
      if (document.body.style.display!="") {
        document.body.style.display = "";
      }
    }
    if (typeof(window.renderFinish)!="undefined") {
      renderFC();
    }
};
function renderFC() {
    if (!_pageFullLoaded) {
     setTimeout(renderFC, 100);
     return;
    }
    window.renderFinish();
}
function __clear() {
  try {
    document.body.oncontextmenu = null;
  }catch(e) {
    return;
  }  
  window.detachEvent("onload", __start);
  _JUICECLASSES = null;
  for (var i in window.LOADSCRIPTS) {
    var c = window.LOADSCRIPTS[i];

    for (var j in c) {
      delete c[j];
    }
    delete window.LOADSCRIPTS[i];
  }
  window.LOADSCRIPTS = null;
  window.STATICCLASS_JWINDOW = null;
  window.JWINDOW_AFTERCLOSE = null;
  window.XWINDOW_AFTERCLOSE = null;
  window.LOADSCRIPT_XML = null;
  window.__xmlpost = null;
  window.__xmlLinkAction = null;
  window.detachEvent("onunload", __clear);
  window.onresize = null;
  window.__closeEvts = null;
  for (var i in __dirtyWins) {
    delete __dirtyWins[i];
  }
  window.__dirtyWins = null;
};


function __render($clDoms) {
    $clDoms = __arrayDoms($clDoms);
    
    for (var i=0; i<$clDoms.length; i++) {
      var dom = $clDoms[i];
      var impl;
    if (window.addEventListener != undefined ){
	    impl = "FatherTree";
	} else if (window.attachEvent != undefined){
	    impl = dom.getAttribute("tt.impl");
	}
      if (impl!=null) {
          /** 如果是WAMenu的类需要特殊处理 */
      	var cmpN = FatherTree;
        var cmp = new cmpN();
        cmp.init(dom);
        if (dom.getAttribute("tt.name")!=null) {
          dom.id = dom.getAttribute("tt.name");
        }
      }
    }//end for
}

function __xmlErrorHandler($xdoc, $outputDom) {
  if ($xdoc.documentElement.tagName=="error") {
    if ($outputDom!=null) {
      $outputDom.innerHTML = "<span style='color:red'>" + $xdoc.documentElement.childNodes[0].text + "</span>";
    }else {
      __alert($xdoc.documentElement.childNodes[0].text);
    }
    return false;
  }
  return true;
}
/**
 * all trust the given dom object it's an array type
 */
function __arrayDoms($doms) {
  if ($doms==null)
    return new Array();
  for (i in $doms) {
    if (i=="length") {
      var tmp = new Array();
      for (var i=0; i<$doms.length; i++) {
        tmp.push($doms[i]);
      }
      return tmp;
    }
    break;
  }
  return new Array($doms);
}
var tbTmp = [];
function __renderSpecialStyle() {
    var tbs = document.all.tags("TABLE");
    var tb = null;
    for (var i=0, len=tbs.length; i<len; i++) {
      tb = tbs[i];
      if (tb.getAttribute("tt.autoHeight")=="true") {
        tb.style.height = document.body.clientHeight - __getPos(tb).y;
        tbTmp.push(tb);
        tb.style.visibility = "visible";
      }
    }
    setTimeout(checkTB, 200);
}
function checkTB() {
    for (var i=0, len=tbTmp.length; i<len; i++) {
      tb = tbTmp[i];
      tb.style.height = document.body.clientHeight - __getPos(tb).y;
    }
}
function __ipRender($domName) {
  var doms = document.all.tags($domName);
  var dom = null;
  for (var i=0, len=doms.length; i<len; i++) {
    dom = doms[i];
    if (dom.readOnly==true || dom.disabled==true) {
    //报错先注销了  __attachClass(dom, "disabled");
    }
  }
}

function __isJwindow() {
  if (parent.STATICCLASS_JWINDOW!=null) {
    return parent.STATICCLASS_JWINDOW.isOpen();
  }
  return document.body.getAttribute("tt.isJwindow")=="true";
}

function __getXmlObject() {
  return new ActiveXObject("Microsoft.XMLDOM");
}

/** get an dom object */
function __get($name, $dom) {
  $dom = $dom || document;
  return $dom.getElementById($name);
}



/**
 * operations of the dom objects style change
 */
function XStyleUtil() {

  var sColorNew = null;
  var sColorOld = null;

  this.activeOverColor      = activeOverColor;
  this.colorOver            = colorOver;
  this.colorOut             = colorOut;

  /**
   * active the over color normal use for a text inside a <td>
   * @param Dom domObj
   * @param String sColor
   */
  function activeOverColor(domObj, sColor) {
    sColorNew = sColor;
    __addEvent(domObj, "onmouseover", colorOver);
    __addEvent(domObj, "onmouseout",colorOut);
  }

  /**
   * text color change when the mouse over
   * @return void
   */
  function colorOver() {
    var domObj = event.srcElement;
    sColorOld = domObj.currentStyle.color;
    domObj.style.color = sColorNew;
  }

  /**
   * text color restore
   * @return void
   */
  function colorOut() {
    var domObj = event.srcElement;
    //alert(sColorNew.toUpperCase())
    if (domObj.style.color.toUpperCase()==sColorNew.toUpperCase())
      domObj.style.color = sColorOld;
  }


}

//mask to a static instance
var StyleUtil = new XStyleUtil();

/**
 * Xml读取的工具类，负责读取请求的xml并返回doc文档，一个只在一个线程中运行
 * 对同进读取的限制在调用类中控制
 * 启动日期： 2002-12-26 14:03
 */
function XmlLoader($async) {

  var oXml = null; //ActiveX控件,MS提供
  var vObservers = []; //观察者链表
  var sProcessKey = null; //进程序的关键字
  var _async = $async;
  	//兼容其他浏览器 
	if (window.addEventListener != undefined ){
	    window.addEventListener("unload", clear, false); 
	} else if (window.attachEvent != undefined){
	    window.attachEvent("onunload", clear);
	}
  

  function clear() {
    if (oXml!=null) {
      oXml.onreadystatechange = new Function("return false;");
      oXml = null;
    }
  }

  /**
   * private 获得一个读取的基类控制，只创建一个
   * @todo 根据IE浏览器版本，返回不同版本的XMLDom控件
   * @return XMLDOM
   */
  function getLoader() {
    if (oXml==null) {
      oXml = __getXmlObject();
      oXml.async = _async; //设置为异步或同步操作
    }
    return oXml;
  }

  /**
   * public 添加一个观察者，在一个xml的异步处理完后，将会通知各个观察者
   * @param observer 观察者实现类
   * @return void
   */
  this.addObserver = addObserver;

  function addObserver(oObserver) {
    vObservers.push(oObserver);
  }

  /**
   * 读取一个xml的文件
   * @param sFile 文件的地址
   * @return void
   */
  this.load = load;

  function load(sFile) {
    sProcessKey = sFile;
    getLoader().load(sFile);
    if (_async) {
      getLoader().onreadystatechange = notify;
    }else {
      notify();
    }
  }

  /**
   * private 读取一个xml的文件，成功后发提示至各个观察者
   * @param sProcessKey
   * @return void
   */
  function notify() {
    var oXml = getLoader();
    if (oXml.readyState == 4){
      var err = oXml.parseError;
      if (err.errorCode!=0)
        oXml = null;

      for (var i=0, len=vObservers.length; i<len; i++) {
        vObservers[i].update(oXml, sProcessKey);
      }
    }//end 读取完毕
  }

  this.destroy = function() {
    if (oXml!=null) {
      oXml.onreadystatechange = new Function("return false");
      oXml.abort();
    }
    clear();

  };
}


/**
 * 核心的数据存放模式哈希表，全框架很多部分代码使用该类，属于基类
 * 使用了数组对象，注意清空其对象的使用
 */
function HashMap() {
  this.put = put;
  this.get = get;
  this.remove = remove;
  this.size = size;
  this.values = values;
  this.keySet = keySet;
  this.toString = toString;
  this.empty = empty;
  this.db = db;

  var _db = new Array();

  /**
   * 存放一个对象
   * @param key 索引字
   * @param value 值
   * @return void
   */
  function put($key, $value) {
    _db[$key] = $value;
  }

  /**
   * 暴露出内部的数据存放对象，减少性能的消耗，不再需要先用
   * keySet再用iterator来访问
   */
  function db() {
    return _db;
  }

  /**
   * 获得一个值
   * @param key 索引
   * @return value
   */
  function get($key) {
    var v = _db[$key];
    if (typeof(v)=="undefined")
      return null;
    return v;
  }

  /**
   * 删除一个key
   * @param key 索引
   */
  function remove($key) {
    var t = get($key);
    delete _db[$key];
    return t;
  }

  /**
   * 获得当前的大小
   * @return int
   */
  function size() {
    var c = 0;
    for (var i in _db){
      c++;
    };
    return c;
  }

  /**
   * 获得全部的索引
   * @return Array()
   */
  function keySet() {
    var t = new Array();
    for (var i in _db) {
      t[t.length] = i;
    }
    return t;
  }

  /**
   * 获得全部的值
   * @return Array()
   */
  function values() {
    var t = new Array();
    for (var i in _db) {
      t[t.length] = _db[i];
    }
    return t;
  }

  /**
   * 清空整个数组
   */
  function empty() {
    _db = [];
  }

  /**
   * 描述其内部的内容
   * @return String
   */
  function toString() {
    var aryKeys = keySet();
    var sTmp = "";
    for (var i in aryKeys) {
      sTmp += aryKeys[i] + " = [ " + get(aryKeys[i]) + " ]\n";
    }
    return sTmp;
  }
}

/**
 * 树型控制的配置模型config model
 * @启动日期 2002-12-26 13:50
 */
function JTreeDefault($insName) {
  this.instance = null; //树的实例
  this.maxPoolSize = 2; //最大的同时读取数
  this.css = "jtree.css";
  this.errorMaxPool = "超过最大线程数，请等候其它线程的任务先完成";
  this.errorThreadRuning = "线程正在进行中，请不要重复按";
  this.errorLoadFile = "读取文件失败";
  this.overNodeColor = "#0000FF";
  this.src = null; //读取数据的地址

  this.imgI = new Image();
  this.imgI.src = _c + "/parts/images/img/jtree/I.gif";
  this.imgL = new Image();
  this.imgL.src = _c + "/parts/images/img/jtree/L.gif";
  this.imgLminus = new Image();
  this.imgLminus.src = _c + "/parts/images/img/jtree/Lminus.gif";
  this.imgLplus = new Image();
  this.imgLplus.src = _c + "/parts/images/img/jtree/Lplus.gif";
  this.imgT = new Image();
  this.imgT.src = _c + "/parts/images/img/jtree/T.gif";
  this.imgTminus = new Image();
  this.imgTminus.src = _c + "/parts/images/img/jtree/Tminus.gif";
  this.imgTplus = new Image();
  this.imgTplus.src = _c + "/parts/images/img/jtree/Tplus.gif";
  this.imgNodeA = new Image();
  this.imgNodeA.src = _c + "/parts/images/img/jtree/L_nodeA.gif";
  this.imgNodeAO = new Image();
  this.imgNodeAO.src = _c + "/parts/images/img/jtree/L_nodeAO.gif";
  this.imgNodeB = new Image();
  this.imgNodeB.src = _c + "/parts/images/img/jtree/L_nodeB.gif";
  this.imgLoading = new Image();
  this.imgLoading.src = _c + "/parts/images/img/jtree/loading.gif";

  this.PRE = $insName; //id对象的前缀，避免与其它组件产生冲突
  this.IMGPRE = this.PRE + "IMG"; //连接图片的前缀
  this.LOADPRE = this.PRE + "LOAD"; //正在下载的前缀
  this.NAMEPRE = this.PRE + "NAME";
  this.last = "<div style='width:16px'/>";
  this.linkImgStyle = "style=\"cursor:hand\"";
  this.imgScript = imgScript;
  this.nameScript = nameScript;


  /**
   * @param sKey 索引关键字
   */
  function imgScript(sKey) {
    return "onmousedown=" + this.instance + ".expandNode('" + sKey + "')";
  }

  /**
   * @param sKey 唯一标识
   */
  function nameScript(sKey) {
    return "onclick=" + this.instance + ".clickNode('" + sKey + "')";
  }
}

/**
 * com.tantom.js.swing.JTree 使用的节点模型基类，[key][name]为强制使用属性 - 不能修改
 */
function TreeNodeModel() {
  this.key = null;
  this.name = null;
  this.hasChild = null;
  this.url = null;
  this.icon = null;
  this.open = null;
  this.level = null;
  this.description = null;
}

/**
 * 树控制，使用动态加载方式，唔写英文注析了，搞到自己都体唔明
 * 启动日期： 2002-12-26 13:41
 * <span id=TreeRoot level=-1></span> 根部的level一定要指定为 -1
 * @rebuild to Juice Componentabled at 2003-12-1 1:20
 * @param mConfig 基本属性的配置
 * @param mNode 一个子的属性配置，需要继承com.tantom.model.swing.TreeNodeModel，只是类的名字，不是实例
 * @author:TANTOM
 * @note: 写的太旧了，都用的好好的不想重写了，虽然复杂了一点可功能都能用，包装了一下到Juice组件规范当中
 */
function JTree($mConfig) {
  this.updateSrc = updateSrc;

  function updateSrc($src) {
    mConfig.src = $src;
  };

  this.loadNode = loadNode;
  this.update = update;
  this.expandNode = expandNode;
  this.clickNode = clickNode;

  this.initNode = initNode;
  var _autoHeightDom = null;
  var _autoHeightSize = 0;
  var _autoHeightFix = 0;
  function initNode($node) {
    _defaultRootDom = $node;
    _autoHeightDom = $node.getAttribute("tt.autoHeight");
    _autoHeightFix = $node.getAttribute("tt.fixHeight")||0;
  };

  this.getRootDom = function() {
    return _defaultRootDom;
  };
  this.reload = reload;

  //获得连接的图片对象，如果返回空表示这个节点没有子
  function getLinkImg($key) {
    return document.getElementById(mConfig.IMGPRE + "L" + $key);
  }
  var _bCheckWhenLoaded = false;
  function reload($key) {
    if ($key==null||$key=="") {
      _defaultRootDom.innerHTML = "";      
      hmLoadedNodes = new HashMap();
      hmNodes = new HashMap();
      loadNode(_defaultRootDom, 0, "2", "1");
    }else {
      var bClose = hmLoadedNodes.get($key);
      if (bClose==null) { //未加载
        //如果本身是没有子的选择的先重新加载父
        var domLinkImg = getLinkImg($key);
        if (domLinkImg==null) { //本身这个节点是没有子的
          var parentNode = getParent($key);
          if (parentNode==null || parentNode.key=="ROOT") { //这是根节点了
            reload();
            return;
          }
          _bAsyn = false;
          reload(parentNode.key); //刷新父
          _bAsyn = true;
          var domLinkImg = getLinkImg($key);
          if (domLinkImg!=null) { //刷新父后发现有子
            expandNode($key);
          }
          return;
        }else {
          expandNode($key);
        }
      }else {
        clearChilds($key);
        if (bClose==true) { //已经加载但被关闭了
          hmLoadedNodes.remove($key);
          expandNode($key);
        }else { //正打开着
          updateImg($key);
          hmLoadedNodes.remove($key);
          expandNode($key);
          //bug fix 2006-4-26reload后这个子应该设置为已加载，且为被关闭
          hmLoadedNodes.put($key, false);
        }
      }//end bClose check
      _bCheckWhenLoaded = true;
    }
  };

  //清除子的状态与外观
  function clearChilds($key) {
    var childs = lookupChilds($key);
    for (var i=0; i<childs.length; i++) {
      var childKey = parseKey(childs[i].getAttribute("id"));
      if (getLinkImg(childKey)!=null) { //这个是有子的，从已加载中去掉
        clearChilds(childKey);
        hmLoadedNodes.remove(childKey);
      }
      childs[i].outerHTML = "";
    }
  }

  /** 自动点击第一个选择的节点 */
  this.clickFirst = clickFirst;

  function clickFirst() {
    clickByIndex(0);
  };

  /** 按序列来点击 */
  this.clickByIndex = clickByIndex;

  function clickByIndex($idx) {
    var keys = hmNodes.keySet();
    if (keys.length==0) {
      return;
    }
    var firstNode = hmNodes.get(keys[$idx]);
    if (firstNode==null) {
      return;
    }
    clickNode(firstNode.key);
  };

  var _defaultRootDom = null;
  var mConfig = $mConfig;
  var objPM = new ProcessManager(mConfig);
  var objPathUtil = new TreePathUtil(mConfig);
  var hmLevelChain = new HashMap(); //保存层次的是否最后一个关系
  var hmLevels = new HashMap(); //保存层次关系的永久值
  var hmLoadedNodes = new HashMap(); //已经加载过的父亲索引
  var hmNodes = new HashMap(); //全部的子的实例保存起来
  //获取树的所有节点对象
  this.getAllNodes = function getAllNodes() {
    return hmNodes;
  };
  
	var _instance = null;
	var _clickNodeFct = null;
	var _objInstance = null;
	var _lastClickNode = null; //最后点中的节点
	var _clickNodeChangeFct = null;
	var _nodeRenderFct = null; //节点内容渲染的方法
	var _nodeOpenFct = null;
	var _nodeCloseFct = null;
	var _nodeLoaded = null;
	

	this.setInstanceName = setInstanceName;

    function setInstanceName($name, $instance) {
		_instance = $name
		_objInstance = $instance;
		mConfig.instance = _instance; //指定实例以便配置时不用再多次转换
		if (eval("window." + $name + "_clickNode")!=null) {
			_clickNodeFct = eval("window." + $name + "_clickNode");
			//_clickNodeFct=function ATree_clickNode($node,$nameDom,$fireEvent);
		}
		if (eval("window." + $name + "_clickNodeChange")!=null) {
			_clickNodeChangeFct = eval("window." + $name + "_clickNodeChange");
			//_clickNodeChangeFct=function ATree_clickNodeChange($node,$nameDom); 在 Control.js 中调用
		}
		//调用接口方法节点渲染
		if (eval("window." + $name + "_nodeRender")!=null) {
			_nodeRenderFct = eval("window." + $name + "_nodeRender");//ATree__nodeRender
		}
		//调用接口方法节点渲染
		if (eval("window." + $name + "_nodeOpen")!=null) {
			_nodeOpenFct = eval("window." + $name + "_nodeOpen");//ATree_nodeOpen
		}
		if (eval("window." + $name + "_nodeClose")!=null) {
			_nodeCloseFct = eval("window." + $name + "_nodeClose");//ATree_nodeClose
		}
		_nodeLoaded = eval("window." + $name + "_loaded");
	};

  /**
   * 选择了一个节点
   * @param sKey 唯一标识
   */


  function clickNode(sKey, $noFireClickEvent) {
  	if (_clickNodeChangeFct!=null) { //先回调node change 方法
  		if (_lastClickNode!=null) {
  		  var nd = getName(_lastClickNode.key);
  		  if (nd!=null) {
  			  _clickNodeChangeFct(_lastClickNode, nd);
  			}
  		}
  	}

  	if (_clickNodeFct!=null) {
  	  _clickNodeFct(hmNodes.get(sKey), getName(sKey), $noFireClickEvent);
  	}
  	_lastClickNode = hmNodes.get(sKey);
  }

  /**
   * 如果是程序调用的选节点
   */
  this.clickNodeManual = clickNodeManual;

  function clickNodeManual(sKey) {
    clickNode(sKey, true);
    /** 自动找寻父亲节点是否已经展开，如果未展开，就先展开 */
    var parentNode = getParent(sKey);
    while (parentNode!=null) {
      var bClose = hmLoadedNodes.get(parentNode.key);      
      if (bClose) {
        updateImg(parentNode.key);
        openNode(parentNode.key);
      }
      parentNode = getParent(parentNode.key);
    }
  };


  /**
   * public 读取一个子的树，会在父亲的Dom对象下获得其子的视图，前题节点是有子的
   * @param domObj 父亲的Dom对象
   * @param sKey 父亲的key值
   * @param iLevel 指定的级别，基本为只获得其一层，但在初始化时是同时获得两层的
   * @return void
   */
  function loadNode(domObj, sKey, iLevel, iType) {

    /**
     * 不指定层数则读取一层 */
    if (iLevel==null)
      iLevel = 1;

    /**
     * 不指定类型，则为向下读取 */
    if (iType==null)
      iType = 1;


    if (!objPM.register(sKey, domObj))
      return;


    /**
     * 显示正在加载几个字
     */
    showLoading(domObj);    
    _XmlLD = new XmlLoader(_bAsyn);
    _XmlLD.addObserver(_objInstance);
    _XmlLD.addObserver(objPM);
    var url = objPathUtil.buildPath(sKey, iLevel, iType);
    _XmlLD.load(url);
  }

  var _XmlLD = null;

  //当指定跟随高度的对象时每次大小变更时就对比高度
  function autoHeightCheck() {

    //更新高度
    if (_autoHeightDom!=null) {
      _defaultRootDom.style.height = "100%";
      var cl = parseInt(__get(_autoHeightDom).style.height) - 11 - _autoHeightFix;
      if (_defaultRootDom.clientHeight>cl) {
        _defaultRootDom.style.height = cl;
      }else {
        _defaultRootDom.style.height = "100%";

      }
    }
  }

  /**
   * public 实现观察者的方法
   * @param sKey 是哪个线程返回的
   * @param oXmlLoader 读取的控制类
   * @return void
   */
  function update(oXml, sLoadPath) {
    if (oXml==null) {
      alert(mConfig.errorLoadFile);
      return;
    }
    var sKey = objPathUtil.parseKey(sLoadPath);
    /** 如果是属于错误信息 */
    var domEKey = getLoad(sKey);
    if (domEKey==null) { //在异步环境当中，前一正在加载的实例在未完成从后台读取数据时被删除了
      return;
    }
    if (!__xmlErrorHandler(oXml, getLoad(sKey).parentElement)) {
      return;
    }

    var sType = objPathUtil.parseType(sLoadPath);
    var domParent = objPM.getProcess(sKey);
    
    paintNode(domParent, oXml.documentElement); //0是编码处理

    /**
     * 删除正在加载的提示
     */
    if (sType==0) //如果是根的话，Loading也是根
      sKey = 0;
    killLoading(sKey);
    autoHeightCheck();

    /** 表示该节点是展开的 */
    hmLoadedNodes.put(sKey, false);
    if (sKey==0) { //这是根，因为在根时返回的子有可能是多级，这时详细处理子中的已读关系
      var fns = oXml.selectNodes("//node");      
      for (var i=0; i<fns.length; i++) {
        if (fns[i].childNodes.length!=0) {
          hmLoadedNodes.put(fns[i].getAttribute("key"), false);
        }
      }
    }

    /**
     * 初始其它属性
     */
    var keys = hmNodes.keySet();
    for (var i=0; i<keys.length; i++) {
    	var mNode = hmNodes.get(keys[i]);
    	/** 显示默认显示是关闭的 */
    	if (mNode.open=="false") {
    		expandNode(mNode.key);
    		mNode.open="";
    	}
    	/** 以后可以在这扩展画完的操作 */
    }

    /**
     * 调用已加载的方法
     */
    if (_nodeLoaded!=null) {
      if (!_noFireTheLoadedEvent) {
        _nodeLoaded(sKey);
      }
    }

    //如果reload一个节点而这个节点已经没有子（因为是动态删除操作）这时要更新连接图标
    if (_bCheckWhenLoaded) { //由程序来触发这个检查
      var lImg = getLinkImg(sKey);
      if (lImg!=null) { //有链接图标的
        var v = lookupChilds(sKey);
        if (v.length==0) { //错误的状态，修正链接图标
          lImg.style.cursor = "default";
          lImg.onmousedown = null;
          lImg.id = mConfig.IMGPRE;
          var src = lImg.src;
          var domNodeImg = document.getElementById(mConfig.IMGPRE + "N" + sKey);//文件夹图标
          if (domNodeImg.src==mConfig.imgNodeAO.src) {
            domNodeImg.src = mConfig.imgNodeA.src;
          }
          if (src==mConfig.imgLminus.src || src==mConfig.imgLplus.src) { // L-
            lImg.src = mConfig.imgL.src
          }else if (src==mConfig.imgTminus.src || src==mConfig.imgTplus.src) { // T-
            lImg.src = mConfig.imgT.src
          }
          hmLoadedNodes.remove(sKey);
        }
      }
      _bCheckWhenLoaded = false;
    }
  }

  /**
   * 在要加载的对象下面显示[正在加载]
   * @param domObj 加载的对象的父亲
   */
  function showLoading(domObj) {
    /**
     * 处理前端的空位，要根据前几层的状态来决定使用的图片
     */
    var nodeLevel = domObj.level*1+1;
    var padHtml = "";
    for (var j=0; j<nodeLevel*1; j++) {
      var img = ""; //pad中图片

      if (hmLevelChain.get(j)==true) { //链表层记录当前操作是最后一个
        img = mConfig.last;
      }else {
        img = "<img id=" + mConfig.IMGPRE + " src=" +mConfig.imgI.src+" align=absbottom >";
      }
      padHtml += "<td style='width:16px'>" + img + "</td>";
    }

    var loadingHtml = "<table  cellspacing=0 cellpadding=0 id=" + mConfig.LOADPRE + parseKey(domObj.id) + " ><tr>"+padHtml+"<td><img src=" + mConfig.imgLoading.src + " align=absbottom></td><td class=nodeName>正在下载...</td></tr></table>";
    domObj.insertAdjacentHTML("beforeEnd", loadingHtml);
  }

  /**
   * 删除一个正在加载的显示
   * @param sKey 唯一标识
   */
  function killLoading(sKey) {
    var domObj = getLoad(sKey);
    domObj.outerHTML = "";
  }

  /**
   * 画出返回的视图
   * @param domParent 视图的父亲dom对象
   * @param oXml xml代码对象
   * @return void
   */
  function paintNode(domParent, oXml) {

    var iLevel = domParent.level; //层级别，如果是根的上一级为-1

    for (var i=0; i<oXml.childNodes.length; i++) {
      var nodeLevel = iLevel*1+1;
      var xmlNode = oXml.childNodes[i];
      var mNode = getModel(xmlNode, nodeLevel);

      /**
       * 处理是否最后一个的状态
       */
      bIsLast = i==oXml.childNodes.length-1;
      hmLevelChain.put(nodeLevel, bIsLast);
      hmNodes.put(mNode.key, mNode);

      /**
       * 模型保存处理
       */
      hmLevels.put(mNode.key, bIsLast);

      /**
       * 处理前端的空位，要根据前几层的状态来决定使用的图片
       * 背景，较麻烦
       */
      var padHtml = "";
      for (var j=0; j<nodeLevel*1; j++) {
        var img = ""; //pad中图片

        if (hmLevelChain.get(j)==true) { //链表层记录当前操作是最后一个
          img = mConfig.last;
        }else {
          img = "<img id=" + mConfig.IMGPRE + " src=" +mConfig.imgI.src+" align=absbottom >";
        }
      	padHtml += "<td style='width:16px'>" + img + "</td>";
      }


      /** 连接的两个图片的视图代码 */
      var imgHtml = ""; //子的图片node
      var xyzPath = "";
      var xyzKey = "";
      var xyzScript = "";
      if (mNode.hasChild=="true") {
        if (xmlNode.hasChildNodes()) {
        	/** 如果配置中有使用icon就使用指定的icon */
        	if (mNode.icon!=null){
        		xyzPath = mNode.icon;
        	}else {
        		xyzPath = mConfig.imgNodeAO.src;
        	}
        }else {
        	/** 如果配置中有使用icon就使用指定的icon */
        	if (mNode.icon!=null){
        		xyzPath = mNode.icon;
        	}else {
        		xyzPath = mConfig.imgNodeA.src;
          }
        }
        xyzKey = "N" + mNode.key;
        xyzScript = "";
      }else {
      	/** 如果配置中有使用icon就使用指定的icon */
      	if (mNode.icon!=null){
      		xyzPath = mNode.icon;
      	}else {
      		xyzPath = mConfig.imgNodeB.src;
    		}
        xyzScript = "";
      }

      /**
       * 更新，如果icon指定值为NONE就是没有ICON也不使用默认的
       */
      if ("NONE"==xyzPath) {
        imgHtml = "";
      }else {
          if (xyzPath.indexOf("/")==0 && xyzPath.indexOf(_c)!=0) {
      	    xyzPath = _c + xyzPath;
      	  }

        imgHtml = "<img id=" + mConfig.IMGPRE + xyzKey + " src=" + xyzPath + " align=absbottom " + xyzScript + ">";
      }

      /** 如果是最后一个显示不同的图标 */
      var linkImgHtml = "";
      xyzPath = "";
      xyzKey = "";
      xyzScript = "";
      var xyzStyle = "";
      if (!bIsLast) { //如果不是最后一个
        if (mNode.hasChild=="true") {
          /**
           * 后台提供的数据可能只指示有子，但没指示下层是否展开
           * 现指定如果有子就开
           */
          if (xmlNode.hasChildNodes()) {
          	xyzPath = mConfig.imgTminus.src;
          }else {
          	xyzPath = mConfig.imgTplus.src;
          }
          /**
           * 对有子的加上脚本控制
           */
          xyzScript = mConfig.imgScript(mNode.key);
          xyzKey = "L" + mNode.key;
          xyzStyle = mConfig.linkImgStyle;
        }else {
          xyzScript = "";
		  xyzKey = "L" + mNode.key;
          xyzPath = mConfig.imgT.src;
        }
        linkImgHtml = "<img id=" + mConfig.IMGPRE + xyzKey +" src=" + xyzPath + " align=absbottom " + xyzScript + " " + xyzStyle + ">";
      }else {
        if (mNode.hasChild=="true") {
          /**
           * 后台提供的数据可能只指示有子，但没指示下层是否展开
           * 现指定如果有子就开
           */
          if (xmlNode.hasChildNodes()) {
          	xyzPath = mConfig.imgLminus.src;
          }else {
          	xyzPath = mConfig.imgLplus.src;
          }
          /**
           * 对有子的加上脚本控制
           */
          xyzScript = mConfig.imgScript(mNode.key);
          xyzKey = "L" + mNode.key;
          xyzStyle = mConfig.linkImgStyle;
        }else {
        	xyzScript = "";
          xyzPath = mConfig.imgL.src;
        }
        linkImgHtml = "<img id=" + mConfig.IMGPRE + xyzKey +" src=" + xyzPath + " align=absbottom " + xyzScript + " " + xyzStyle + ">";

      }

      /** 生成子<Table>的视图的代码 */
			var nodeHtml = [];
			nodeHtml.push("<table width=100% cellspacing=0 cellpadding=0><tr>");
			nodeHtml.push(padHtml);
			nodeHtml.push("<td>");
			nodeHtml.push(linkImgHtml);
			nodeHtml.push("</td><td>");
			nodeHtml.push(imgHtml);
			nodeHtml.push("</td><td width=100% id=");
			nodeHtml.push(mConfig.NAMEPRE);
			nodeHtml.push(mNode.key);
			nodeHtml.push(" ");
			nodeHtml.push(mConfig.nameScript(mNode.key));
			nodeHtml.push(" class=nodeName>");
			if (_nodeRenderFct!=null) {
				nodeHtml.push(_nodeRenderFct(mNode));
			}else {
				nodeHtml.push(mNode.name);
			}
			nodeHtml.push("</td></tr></table>");
			nodeHtml = nodeHtml.join("");


			var levelHtml = [];
			levelHtml.push("<span id=");
			levelHtml.push(mConfig.PRE);
			levelHtml.push(mNode.key);
			levelHtml.push(" class=TreeNode level=");
			levelHtml.push(nodeLevel);
			levelHtml.push(">");
			levelHtml.push(nodeHtml);
			levelHtml.push("</span>");
      levelHtml = levelHtml.join("");

      domParent.insertAdjacentHTML("beforeEnd", levelHtml);

      /** 激活当鼠标移至上方时，颜色的变化 */
      var d = getName(mNode.key);
      if (d==null) {
        return;
      }
      StyleUtil.activeOverColor(d, mConfig.overNodeColor);
      paintNode(getDom(mNode.key), xmlNode);
    }
  }

  /**
   * 用户点选中一个可展开或者收缩的节点
   * @param sKey 节点的索引值 WYS打开节点部分
   * @return void
   */


  function expandNode(sKey) {
    if (!objPM.isRunable())
      return;

    var domObj = getDom(sKey);

    if (domObj==null) {
      return;
    }

    /**
     * 修改图标的视图
     */
    var bOpen = updateImg(sKey);

    if (!bOpen) { //关闭操作
      closeNode(sKey);
      autoHeightCheck();
      return;
    }

    //读取操作，先查看是否已经加载这个子，如果没有才加载，如果有直接显示
    if (hmLoadedNodes.get(sKey)!=null) {
      openNode(sKey);
      autoHeightCheck();
      return;
    }
    /**
     * 重新获得链表的状态   读取数据库打开节点
     */
    rebuildChain(sKey);
	//WYS alert(domObj+"   "+sKey);
    loadNode(domObj, sKey);
    
    //韩飞新增 调用外部open方法进行关闭其他操作
    if (_nodeOpenFct!=null) {
		_nodeOpenFct(sKey);
    }
  }
  
  /**
   * 更新视图的图片
   * @param sKey 唯一索引
   * @return boolean 是否展开操作，否表示是关闭操作
   */
   this.updateImg = updateImg;
  function updateImg(sKey) {
    var domObj = getDom(sKey);
    var domLinkImg = document.getElementById(mConfig.IMGPRE + "L" + sKey);
    var domNodeImg = document.getElementById(mConfig.IMGPRE + "N" + sKey);

    //先处理连接位置
    var bType = false;
    if (domLinkImg.src==mConfig.imgLminus.src) { // L-
      domLinkImg.src = mConfig.imgLplus.src;
      bType = false;
    }else if (domLinkImg.src==mConfig.imgLplus.src) { // L+
      domLinkImg.src = mConfig.imgLminus.src;
      bType = true;
    }else if (domLinkImg.src==mConfig.imgTminus.src) { // T-
      domLinkImg.src = mConfig.imgTplus.src;
      bType = false;
    }else if (domLinkImg.src==mConfig.imgTplus.src) { // T+
      domLinkImg.src = mConfig.imgTminus.src;
      bType = true;
    }

    //子图片处理
    if (domNodeImg!=null) { //如果使用NONE属性时这个会为空
        if (domNodeImg.src==mConfig.imgNodeA.src) {
          domNodeImg.src = mConfig.imgNodeAO.src;
        }else if (domNodeImg.src==mConfig.imgNodeAO.src) {
          domNodeImg.src = mConfig.imgNodeA.src;
        }
    }
    return bType;
  }
	
  /** 韩飞
   * 判断当前节点的图片是否关闭
   * @param sKey 唯一索引
   * @return boolean 是否展开操作，true表示已关闭状态
   */
   this.judgeImg = judgeImg;
  function judgeImg(sKey) {
    var domObj = getDom(sKey);
    var domLinkImg = document.getElementById(mConfig.IMGPRE + "L" + sKey);
    var domNodeImg = document.getElementById(mConfig.IMGPRE + "N" + sKey);
    //先处理连接位置
    var bType = false;
    if (domLinkImg.src==mConfig.imgLminus.src) { // L-
      bType = false;
    }else if (domLinkImg.src==mConfig.imgLplus.src) { // L+
      bType = true;
    }else if (domLinkImg.src==mConfig.imgTminus.src) { // T-
      bType = false;
    }else if (domLinkImg.src==mConfig.imgTplus.src) { // T+
      bType = true;
    }
    return bType;
  }
  
  /**
   * 关闭一个节点
   * @param sKey 节点的标识
   */
  this.closeNode = closeNode;

  function closeNode(sKey) {
  	//alert("关闭节点")  
    var vChildNodes = lookupChilds(sKey);
    for (var i=0,len=vChildNodes.length; i<len; i++) {
      vChildNodes[i].style.display = "none";
    }
    //把这个标记加入至索引，表示是加载过但被隐藏了
    hmLoadedNodes.put(sKey, true);

    //调用外部方法
    if (_nodeCloseFct!=null) {
      _nodeCloseFct(sKey);
    }
  }

  /**
   * 打开一个节点
   * @param sKey 节点的标识
   */
  this.openNode = openNode;

  function openNode(sKey) {
  //alert("不读数据库打开节点")  
    var vChildNodes = lookupChilds(sKey);
   	for (var i=0,len=vChildNodes.length; i<len; i++) {
      vChildNodes[i].style.display = "";
    }
    //把这个标记加入至索引，表示是加载过但被隐藏了
    hmLoadedNodes.put(sKey, false);

    //调用外部方法
    if (_nodeOpenFct!=null) {
      _nodeOpenFct(sKey);
    }
  }
  
  /**  韩飞
   * 只打开一个节点 需用外部_nodeOpenFct方法调用
   * @param $key 节点的标识
   */
	this.openNodeOne = openNodeOne;
	function openNodeOne($key) {
		var parentModel = getParent($key);//获得父级节点对象
		var childsModel;  //获得父级节点下的所有子节点
		if(parentModel==null){
			childsModel = getChildsModel($key);
		}else{
			childsModel = getChildsModel(parentModel.key);
		}
		if(childsModel.length>0){ //判断当前$key节点的父节点的子节点
			var init = $key=="ROOT"?childsModel[0].key:$key; //如果$key为ROOT，则以第一个子节点为当前节点
			for(var i=0;i<childsModel.length;i++){
				if(childsModel[i].key != init ){ //判断子节点是否是当前节点
					var childsModelc = getChildsModel(childsModel[i].key); //获得所有子节点
					if(childsModelc.length>0){ //判断子节点是否有子节点
						if(!judgeImg(childsModel[i].key)){ //判断子节点是否关闭
							//更新关闭图片
							var bOpen = updateImg(childsModel[i].key);
						    if (!bOpen) { //关闭操作
						    	closeNode(childsModel[i].key);
						    }
					    }
					}
			    }
			}
		}
	}
	
  /**
   * 某个节点是否已经加载过
   */
  this.isNodeLoaded = isNodeLoaded;

  function isNodeLoaded($nodeId) {
    return hmNodes.get($nodeId)!=null;
  };

  /**
   * 该节点是否当前正被点选的节点
   */
  this.isSelectingNode = isSelectingNode;

  function isSelectingNode($nodeId) {
    return _lastClickNode==hmNodes.get($nodeId);
  };

  var _bAsyn = true; //默认都是以异步来操作，但在特殊的时候如自动展开某个深度的节点时需要是同步
  /**
   * 根据全地址的语法 AAA.BBB.CCC 来展开树
   */
  this.expandByPathSyntax = expandByPathSyntax;
  var _noFireTheLoadedEvent = false;
  function expandByPathSyntax($fullPath) {
    var paths = $fullPath.split(".");
    var nodeKey = null;
    var bClose = null;
    var self = paths.pop(); //自己是不用处理的
    _noFireTheLoadedEvent = true;
    for (var i=0; i<paths.length; i++) {
      nodeKey = paths[i];
      bClose = hmLoadedNodes.get(nodeKey);      
      if (bClose==null) { //该节点还没有加载
        _bAsyn = false;

        expandNode(nodeKey);      
        _bAsyn = true;
      }else { //已经加载了该节点
        if (bClose) {
          updateImg(nodeKey);
          openNode(nodeKey);
        }
      }
    }
    if (self=="") {
      return;
    }
    clickNode(self, true);
    _noFireTheLoadedEvent = false;
  };

  /**
   * 获得新的链表
   * @param sKey 用于构建其父链表的对象
   */
  function rebuildChain(sKey) {
    hmLevelChain.empty();
    var domParent = getDom(sKey);

    do {
    //alert(domParent.level+"    "+hmLevels.get(key));
      var key = parseKey(domParent.id);
      var level = domParent.level;
      hmLevelChain.put(level, hmLevels.get(key));
    }while ((domParent = lookupParent(parseKey(domParent.id)))!=null)
  }

  /**
   * 获得一个父亲，如果已经到了最高层的父亲，就返回null
   * @param sKey 唯一标识
   * @return domObj
   */
  function lookupParent(sKey) {
    var domSelf = getDom(sKey);
    if (domSelf == null)
        return null; 
    var domParent = domSelf.parentElement;
    //alert("domParent=="+domParent.level);
    if (domParent.level==-1)
      return null;
    return domParent;
  }

  //外部指明要执行该方法，如同一树被重复调用时，异步处理需要即时清理时请使用该方法
  this.destroy = function() {
    if (_XmlLD!=null) {
      _XmlLD.destroy();
    }
  };

  this.getParent = getParent;

  function getParent($key) {
    var dom = lookupParent($key);
    if (dom==null) {
      return null;
    }
    var sKey = parseKey(dom.id);
    return hmNodes.get(sKey);
  };

  this.getNodeModel = function getNodeModel(sKey) {
    return hmNodes.get(sKey);
  };

  /**
   * 查找子对象集合
   * @param sKey 唯一标识
   * @return Collection dom的集合
   */
  function lookupChilds(sKey) {
    var domObj = getDom(sKey);
    var vTmp = [];
    if(domObj!==null){
	    for (var i=1, len=domObj.children.length; i<len; i++) {
	      vTmp.push(domObj.children[i]);
	    }
    }
    return vTmp;
  }
  
  //获得某个节点的第一个子节点
  this.getChildsModel = function getChildsModel(sKey) {
    var childs = lookupChilds(sKey);
    var ret = [];
    for (var i=0; i<childs.length; i++) {
      var domId = childs[i].getAttribute("id");
      var k = parseKey(domId);
      ret.push(hmNodes.get(k));
    }
    return ret;
  };

	var reg = new RegExp(mConfig.PRE + "(.*)");
  /**
   * 解析出唯一标识
   * @sId
   */
  this.parseKey = function parseKey(sId) {
    return sId.match(reg)[1];
  }

  /**
   * 根据一个节点的xml解析成一个Javascript使用的模型
   * @param xdomElement Xml的dom对象
   * @return mNode 初始化时确定使用的模型
   */
  function getModel(xdomElement, nodeLevel) {
    var mNode = new TreeNodeModel();
    mNode.key = xdomElement.getAttribute("key");
  	mNode.name = xdomElement.getAttribute("name");
  	mNode.hasChild = xdomElement.getAttribute("hasChild");
  	mNode.url = xdomElement.getAttribute("url");
  	mNode.urls = xdomElement.getAttribute("urls");
  	mNode.icon = xdomElement.getAttribute("icon");
  	mNode.open = xdomElement.getAttribute("open");
  	mNode.level = nodeLevel;
    mNode.description = xdomElement.getAttribute("description");
    return mNode;
  }



  /**
   * 获得Dom对象
   * @param sKey 唯一标识
   * @return domObj
   */
  this.getDom = getDom;

  function getDom(sKey) {
    return document.getElementById(mConfig.PRE + sKey);
  }

  /**
   * 获得显示正在加载的对象
   * @param sKey 唯一标识
   * @return domObj
   */
  function getLoad(sKey) {
    return document.getElementById(mConfig.LOADPRE + sKey);
  }

  /**
   * 获得显示name的Dom节点
   * @param sKey 唯一标识
   * @return domObj
   */
  this.getName = getName;

  function getName(sKey) {
    return document.getElementById(mConfig.NAMEPRE + sKey);
  }

} //JTree 类结束

//------------------------------------------------------------------
/**
 * 进程管理帮助类
 */
function ProcessManager(mConfig) {

  this.register = register;
  this.update = update;
  this.getProcess = getProcess;
  this.isRunable = isRunable;

  var hmPool = new HashMap();
  var objPathUtil = new TreePathUtil(mConfig);

  /**
   * 检查是否允许操作
   * @return
   */
  function isRunable(sKey) {
    /** 不允许同时点选过多的节点操作 */
    if (hmPool.size()>=mConfig.maxPoolSize) {
      alert(mConfig.errorMaxPool);
      return false;
    }

    /** 同一地址正在进行中 */
    if (hmPool.get(sKey)!=null) {
      alert(mConfig.errorThreadRuning);
      return false;
    }
    return true;
  }

  /**
   * 将一个进程登记至管理器中
   * @param sKey 进程关键字
   * @param domObj 操作对象，在操作完成时，会返回给控制类
   * @return boolean
   */
  function register(sKey, domObj) {
    if (!isRunable(sKey))
      return false;

    hmPool.put(sKey, domObj);
    return true;
  }

  /**
   * 获得进程的操作对象
   * @return domObj
   */
  function getProcess(sKey) {
    return hmPool.get(sKey);
  }

  /**
   * public 实现观察者的方法，删除进程
   * @param oXml 读取控制类
   * @param sKey 线程关键字
   * @return void
   */
  function update(oXml, sLoadPath) {
    var sKey = objPathUtil.parseKey(sLoadPath);
    unRegister(sKey);
  }

  /**
   * private 取消一个进程
   * @param sKey 进程序关键字
   * @return void
   */
  function unRegister(sKey) {
    hmPool.remove(sKey);
  }
}//ProcessManager结束

//------------------------------------------------------------------
/**
 * 地址相互转换类
 */
function TreePathUtil(mConfig) {

  this.buildPath = buildPath;
  this.parseKey = parseKey;
  this.parseType = parseType;

  var reg = /^.*[\?|\&]key\=([^\&]*)/;
  var regType = /^.*[\?|\&]type\=([^\&]*)/;
  /**
   * public 创建读取的地址
   * @param sKey key值
   * @param iLevel 层数
   * @return 真正的读取地址 WYS 重点 传值给XML文件用于重新加载
   */
  function buildPath(sKey, iLevel, iType) {
  //alert(sKey+"  "+ iLevel+"  "+iType);
    if (iLevel==null)
      iLevel = 1;

    if (iType==null)
      iType = 1;

		sLoadPath = "";
		if (mConfig.src.indexOf("?")!=-1) {
			sLoadPath = mConfig.src + "&key=" + sKey + "&level=" + iLevel + "&type=" + iType ;
		}else {
      sLoadPath = mConfig.src + "?key=" + sKey + "&level=" + iLevel + "&type=" + iType ;
      //alert("sLoadPath=="+sLoadPath);
  	}
    return sLoadPath;
  }

  /**
   * public 从地址中解析出key的关键字
   * @param sLoadPath
   */
  function parseKey(sLoadPath) {
    var sKey = sLoadPath.match(reg)[1];
    return sKey;
  }

  /**
   * 解析出地址综合的sType
   * @param sLoadPath 地址
   * @return type
   */
  function parseType(sLoadPath) {
    var sType = sLoadPath.match(regType)[1];
    return sType;

  }
}

function FatherTree() {
	/**
	 * component framework must implement method
	 */
	var tree = null;
	var dom = null;
	this.init = init;

    function init($dom) {

	    dom = $dom;
		var src = dom.getAttribute("tt.src");
		var instance = dom.getAttribute("tt.instance");
        var config = null;
        if (typeof(window.JTreeModel)!="undefined") {
          config = new JTreeModel(instance);
        }else {
          config = new JTreeDefault(instance);
        }
        //__loadCss(config.css);
		config.src = src;
		tree = new JTree(config);
		tree.setInstanceName(instance, tree);
		eval("window." + instance + "=tree");

		dom.setAttribute("id", config.PRE + "0");
		dom.setAttribute("level", "-1");
        tree.initNode(dom);
		if (dom.getAttribute("tt.lazy")==null) {
		  var ran = Math.random() * 300 + 100;
		  setTimeout(loadTree, ran);
		}else {

		}
	};

	this.loadTree = loadTree;

    function loadTree() {
      tree.loadNode(dom, 0, "2", "1");
	}
}
